package com.tvunetworks.center.device.controller.feign;

import com.tvunetworks.center.common.feign.customized.CustomizedDeviceFeignInterface;
import com.tvunetworks.center.common.model.param.GetIdleChannelParam;
import com.tvunetworks.center.common.model.param.customized.RegistAnywhereAndPairRParam;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.common.util.ResultUtil;
import com.tvunetworks.center.device.service.CustomizedCCService;
import com.tvunetworks.center.device.service.CustomizedLiveService;
import com.tvunetworks.center.device.service.DeviceExtraService;
import com.tvunetworks.center.gs.model.Device;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: tvucc-aggregator
 * @description: CustomizedDeviceFeignController
 * @author lebronchen
 * @create: 2020-03-18 18:19
 **/
@RestController
@RequestMapping("/feign/customized/device")
@Slf4j
public class CustomizedDeviceFeignController implements CustomizedDeviceFeignInterface {

    @Autowired
    private DeviceExtraService deviceExtraService;
    @Autowired
    private CustomizedLiveService customizedLiveService;
    @Autowired
    private CustomizedCCService customizedCCService;

    @Override
    public List<String> listAutoPeerIds() {
        return deviceExtraService.listCacheAutoPeerIds();
    }


    @Override
    public Result<Device> getIdleChannel(@RequestBody GetIdleChannelParam param) {
        Device r = customizedLiveService.getIdleChannel(param);
        return ResultUtil.success(r);
    }

    @Override
    public Result<String> registAnywhereAndPairR(@RequestBody RegistAnywhereAndPairRParam param) {
        customizedCCService.registAnywhereAndPairR(param);
        return ResultUtil.success();
    }

    @Override
    public Result<String> pairTR(@RequestParam("rid") String rid, @RequestParam("tid") String tid) {
        customizedCCService.pairTR(rid, tid);
        return ResultUtil.success();
    }
}
